﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;

namespace EnvControlLib
{
    /// <summary>
    /// 输入框
    /// </summary>
    public partial class MessageWindow : Window
    {
        #region 构造函数

        private MessageWindow()
        {
            InitializeComponent();

            // 注册系统事件
            okButton.Click += new RoutedEventHandler(okButton_Click);
            cancelButton.Click += new RoutedEventHandler(cancelButton_Click);
        }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="isHideCancelButton">隐藏“取消”按钮</param>
        public MessageWindow(bool isHideCancelButton = false)
            : this()
        {
            if (isHideCancelButton) // 确定隐藏“取消”按钮
                cancelButton.Visibility = Visibility.Collapsed;
        }

        #endregion

        #region 系统事件

        private void okButton_Click(object sender, RoutedEventArgs e)
        {
            if (string.IsNullOrWhiteSpace(NoticeBoxText))
            {
                MessageBox.Show("请输入内容！", "温馨提示");
                return;
            }

            this.DialogResult = true;
        }

        private void cancelButton_Click(object sender, RoutedEventArgs e)
        {
            this.DialogResult = false;
        }

        #endregion

        #region 属性

        public string NoticeBoxText
        {
            get
            {
                return this.noticeBox.Text;
            }
        }

        #endregion
    }
}
